package io;


import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
/**
 * 对象流
 * java.io.ObjectOutputStream和ObjectInputStream
 * 对象流是一对高级流,作用是进行对象序列化与反序列化
 * 对象序列化:将一个java对象按照其结构和内容转换为一组字节的过程.反之为对象反序列化.
 */
public class OOSDemo {
    public static void main(String[] args) throws IOException {
        String name = "GGG";
        int age = 111;
        String gender = "男";
        String  otherInfo = "safsfsfsf";
        FileOutputStream fos = new FileOutputStream("person.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        Person ppp = new Person(name, age, gender, otherInfo);
        oos.writeObject(ppp);
        System.out.println("写出完毕");
        oos.close();
    }
}
